#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    this->model = new QFileSystemModel(this);
    this->model->setRootPath(QDir::currentPath());
    ui->treeView->setModel(this->model);
    auto rootModelIndex = this->model->index(R"(E:\\test_workspace)"); // 获取d盘在模型中的索引
    ui->treeView->setRootIndex(rootModelIndex); // 设置树视图的根索引为d盘在模型中的索引
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_treeView_clicked(const QModelIndex &index)
{
    ui->plainTextEdit->appendPlainText(this->model->filePath(index));
}
